package com.wisezone.workflow.core;

import java.util.List;
import java.util.Map;

import com.wisezone.common.Pagination;
import com.wisezone.workflow.bean.WfProcessDefinition;
import com.wisezone.workflow.bean.form.WorkFlowForm;
import com.wisezone.workflow.bean.po.PositionModule;
import com.wisezone.workflow.bean.search.WfProcessDefinitionSearch;
import com.wisezone.workflow.bean.search.WfProcessInstanceSearch;
import com.wisezone.workflow.bean.search.WorkFlowSearch;
import com.wisezone.workflow.exception.WfCoreException;

/**
 * 流程引擎类
 * @author tss 2009-09-05
 *
 */
public interface FlowEngine extends BaseProperty {

	
	/**
	 * 根据流程标识加载流程模板
	 * @param name
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessDefinition loadProcessDefByKey(String key) throws WfCoreException;
	
	
	/**
	 * 根据ID加载流程模板
	 * @param id
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessDefinition loadProcessDefById(Long id) throws WfCoreException;
	
	/**
	 * 根据ID加载活动
	 * @param id 活动Id
	 * @return
	 * @throws WfCoreException
	 */
	public Activity loadActivity(Long id) throws WfCoreException;
	
	
	/**
	 * 根据流程实例ID 加载流程实例
	 * @param id
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance loadProcessInstance(Long id) throws WfCoreException;
	
	/**
	 * 发起一个流程实例
	 * @param key
	 * @param variableMap
	 * @param starter
	 * @throws WfCoreException
	 */
	public ProcessInstance startProcessInstByKey(String key,String porcessInstName,Map<String, Object> variableMap,Long starter) throws WfCoreException;
	
	
	/**
	 * 发起流程并完成开始活动
	 * @param map
	 * @return
	 * @throws WfCoreException
	 */
	public WorkFlowForm complateStartActivity(WorkFlowSearch searchEntity) throws WfCoreException;
	
	/**
	 * 活动操作
	 * @param searchEntity
	 * @return
	 * @throws WfCoreException
	 */
	public WorkFlowForm operateActivity(WorkFlowSearch searchEntity) throws WfCoreException;
	
	/**
	 * 根据ID 加载活动实例
	 * @param id
	 * @return
	 * @throws WfCoreException
	 */
	public ActivityInstance loadActivityInstance(Long id) throws WfCoreException;

	
	/**
	 * 获得流程模板
	 * @param wfProcess
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessDefinition getProcessDefinition(WfProcessDefinitionSearch searchEntity) throws WfCoreException;
	
	   /**
	 * 当前流程实例相关表单信息查询(分页)
	 * @param hql
	 * @param searchEntity
	 * @return
	 * @throws Exception
	 */
	public<T> Pagination<T> listProcessInstByPage(WorkFlowSearch searchEntity) throws WfCoreException;
	
	
	/**
	 * 获得流程模版定义列表
	 * @param searchEntity
	 * @return
	 * @throws WfCoreException
	 */
	public List<ProcessDefinition> listProcessDefinition(WfProcessDefinitionSearch searchEntity) throws WfCoreException;
	
	/**
	 * 获得当前流程实例节点信息
	 * @param processInstId
	 * @return
	 * @throws WfCoreException
	 */
	public List<PositionModule> getPositions(Long processInstId) throws WfCoreException;
	
	/**
	 * 保存流程模板
	 * @param jsonStr
	 * @throws WfCoreException
	 */
	public void save(WfProcessDefinition entity) throws WfCoreException;
	
	/**
	 * 修改流程模板
	 * @param jsonStr
	 * @throws WfCoreException
	 */
	public void update(Long id,String jsonStr) throws WfCoreException;
	
	/**
	 * 流程发布(覆盖)
	 * @param filePath
	 * @throws WfCoreException
	 */
	public void publish(Long id) throws WfCoreException;
	
	/**
	 * 提交，作为最终数据交互
	 * @param pi
	 * @throws WfCoreException
	 */
	public void submit(ProcessInstance pi) throws WfCoreException;
	
	/**
	 * 提交，作为最终数据交互
	 * @param ai
	 * @throws WfCoreException
	 */
	public void submit(ActivityInstance ai) throws WfCoreException;
	
    
    	
	
	
	
	
	
}
